package one.test;

import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;

public class MyClassLoaderTwo extends ClassLoader {


    public static void main(String[] args) {
        String filePath = "file:/C:/Users/Administrator/Desktop/";
        URLClassLoader urlClassLoader = (URLClassLoader) MyClassLoaderTwo.class.getClassLoader();
        try {
            Method member = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
            member.setAccessible(true);
            URL url = new URL(filePath);
            member.invoke(urlClassLoader, url);
            Class c = Class.forName("Hello");
            Object o = c.newInstance();
            Method method = c.getMethod("hello", null);
            method.invoke(o, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
